///***********************************************
///文件描述：
///创建人：dgg108698
///创建时间：2020/9/14
///修改人：
///修改时间：
///修改备注：
///***********************************************

class DggInterceptor {
  Future<DggRequestOptions> onRequest(DggRequestOptions options) async =>
      options;

  Future<DggResponse> onResponse(DggResponse response) async => response;
}

class DggRequestOptions {
  ///请求方法
  final String method;

  ///请求链接
  final String path;

  ///请求头
  final Map<String, dynamic> headers;

  ///请求体
  final dynamic data;

  DggRequestOptions({
    this.method,
    this.path,
    this.data,
    this.headers,
  });

  DggRequestOptions merge({
    String method,
    String path,
    dynamic data,
    Map<String, dynamic> headers,
  }) {
    return DggRequestOptions(
      method: method ?? this.method,
      path: path ?? this.path,
      data: data ?? this.data,
      headers: headers ?? this.headers,
    );
  }
}

class DggResponse<T> {
  final Map<String, List<String>> headers;

  final T data;

  DggResponse({this.headers, this.data});

  DggResponse<T> merge({Map<String, List<String>> headers, T data}) {
    return DggResponse<T>(
      headers: headers ?? this.headers,
      data: data ?? this.data,
    );
  }
}
